<template>
  <div class="socket">
    socket
  </div>
</template>

<script>
import io from 'socket.io-client';

export default {
  name: 'socket',
  components: {
  },
  data() {
    return {
      socket: null
    };
  },
  mounted() {
    this.socket = io('http://127.0.0.1:3000');
    this.socket.on('connect', () => {
      console.log('连接成功');
    });
    this.socket.on('event', (data) => {
      console.log(data);
    });
    this.socket.on('disconnect', () => {
      console.log('连接关闭');
    });
    this.socket.emit('room', {
      roomId: 9999,
      userName: '测试',
      userType: 0
    });
  },
  methods: {

  },
  watch: {
  },
  computed: {
  }
};
</script>

<style lang="less">
</style>
